home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / mawk10.zip / MAKESCAN.C < prev    next >
C/C++ Source or Header  |  1991-10-05  |  3KB  |  130 lines

  1.  
  2. /********************************************
  3. makescan.c
  4. copyright 1991, Michael D. Brennan
  5.  
  6. This is a source file for mawk, an implementation of
  7. the AWK programming language.
  8.  
  9. Mawk is distributed without warranty under the terms of
  10. the GNU General Public License, version 2, 1991.
  11. ********************************************/
  12.  
  13. /*$Log:    makescan.c,v $
  14.  * Revision 3.2.1.1  91/09/14  17:23:42  brennan
  15.  * VERSION 1.0
  16.  * 
  17.  * Revision 3.2  91/06/28  04:17:00  brennan
  18.  * VERSION 0.999
  19.  * 
  20.  * Revision 3.1  91/06/07  10:27:51  brennan
  21.  * VERSION 0.995
  22.  * 
  23.  * Revision 2.1  91/04/08  08:23:29  brennan
  24.  * VERSION 0.97
  25.  * 
  26. */
  27.  
  28. /* source for makescan.exe which builds the scancode[]
  29.    via:   makescan.exe > scancode.c
  30. */
  31.  
  32. #ifdef THINK_C
  33. #include <stdio.h>
  34. #include <console.h>
  35. #include <string.h>
  36. #define SIZE_T(x) (size_t)(x)
  37. #endif
  38.  
  39. #ifndef SIZE_T
  40. #define SIZE_T(x) (x)
  41. #endif
  42.  
  43. #define  MAKESCAN
  44.  
  45. #include  "scan.h"
  46.  
  47. char   scan_code[256] ;
  48.  
  49. void  scan_init()
  50.   register char *p ;
  51.  
  52.   (void) memset(scan_code, SC_UNEXPECTED, SIZE_T(sizeof(scan_code))) ;
  53.   for( p = scan_code + '0' ; p <= scan_code + '9' ; p++ )
  54.        *p = SC_DIGIT ;
  55.   scan_code[0] = 0 ;
  56.   scan_code[ ' ' ] = scan_code['\t'] = scan_code['\f'] = SC_SPACE ;
  57.   scan_code[ '\r'] = scan_code['\013'] = SC_SPACE ;
  58.  
  59.   scan_code[';'] = SC_SEMI_COLON ;
  60.   scan_code['\n'] = SC_NL ;
  61.   scan_code['{'] = SC_LBRACE ;
  62.   scan_code[ '}'] = SC_RBRACE ;
  63.   scan_code['+'] = SC_PLUS ;
  64.   scan_code['-'] = SC_MINUS ;
  65.   scan_code['*'] = SC_MUL ;
  66.   scan_code['/'] = SC_DIV ;
  67.   scan_code['%'] = SC_MOD ;
  68.   scan_code['^'] = SC_POW ;
  69.   scan_code['('] = SC_LPAREN ;
  70.   scan_code[')'] = SC_RPAREN ;
  71.   scan_code['_'] = SC_IDCHAR ;
  72.   scan_code['='] = SC_EQUAL ;
  73.   scan_code['#'] = SC_COMMENT ;
  74.   scan_code['\"'] = SC_DQUOTE ;
  75.   scan_code[','] = SC_COMMA ;
  76.   scan_code['!'] = SC_NOT ;
  77.   scan_code['<'] = SC_LT ;
  78.   scan_code['>'] = SC_GT ;
  79.   scan_code['|'] = SC_OR ;
  80.   scan_code['&'] = SC_AND ;
  81.   scan_code['?'] = SC_QMARK ;
  82.   scan_code[':'] = SC_COLON ;
  83.   scan_code['['] = SC_LBOX ;
  84.   scan_code[']'] = SC_RBOX ;
  85.   scan_code['\\'] = SC_ESCAPE ;
  86.   scan_code['.'] = SC_DOT ;
  87.   scan_code['~'] = SC_MATCH ;
  88.   scan_code['$'] = SC_DOLLAR ;
  89.  
  90.   for( p = scan_code + 'A' ; p <= scan_code + 'Z' ; p++ )
  91.        *p = *(p + 'a' - 'A') = SC_IDCHAR ;
  92.  
  93. }
  94.  
  95. void scan_print()
  96. { register char *p = scan_code ;
  97.   register int c ; /* column */
  98.   register int r ; /* row */
  99.  
  100.   printf("\n\n/* scancode.c */\n\n\n") ;
  101.   printf( "char scan_code[256] = {\n" ) ;
  102.  
  103.   for( r = 1 ; r <= 16 ; r++)
  104.   {
  105.     for( c = 1 ; c <= 16 ; c++)
  106.     {
  107.       printf("%2d" , *p++) ;
  108.       if ( r != 16 || c != 16 )  putchar(',') ;
  109.     }
  110.     putchar('\n') ;
  111.   }
  112.  
  113.   printf("} ;\n") ;
  114. }
  115.  
  116.  
  117. int main(argc,argv)
  118. int argc;
  119. char **argv;
  120. {
  121. #ifdef THINK_C
  122. fprintf(stderr, "MAKESCAN for MacMAWK\n");
  123. SetWTitle( FrontWindow(), "\pPC-KIMMO");
  124. argc = ccommand(&argv);
  125. #endif
  126.   scan_init() ; scan_print() ;
  127.   return 0 ;
  128. }
  129.